package com.yunyi.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yunyi.common.core.domain.AjaxResult;
import com.yunyi.system.domain.ConsultationReport;
import com.yunyi.system.domain.EmrCaseLog;
import com.yunyi.system.service.EmrCaseLogService;
import com.yunyi.system.mapper.EmrCaseLogMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author Sekiro
* @description 针对表【emr_case_log(会诊日志)】的数据库操作Service实现
* @createDate 2023-09-15 11:28:11
*/
@Service
public class EmrCaseLogServiceImpl extends ServiceImpl<EmrCaseLogMapper, EmrCaseLog>
    implements EmrCaseLogService{

    @Resource
    private EmrCaseLogMapper caseLogMapper;

    @Override
    public AjaxResult consultationReport(ConsultationReport report) {
        boolean empty = report.getDateRange() == null || report.getDateRange().isEmpty();
        PageHelper.startPage(report.getPageNum(), report.getPageSize());
        List<EmrCaseLog> emrCaseLogs = caseLogMapper.consultationReport(report.getStatus(), report.getPathologyType(), report.getCondition(),empty?null:report.getDateRange().get(0),empty?null:report.getDateRange().get(1));
        PageInfo<EmrCaseLog> logInfos = new PageInfo<>(emrCaseLogs);
        return emrCaseLogs == null ? AjaxResult.error("暂无数据") : AjaxResult.success("获取会诊报表",logInfos);
    }
}




